home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 288 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Are macros expanded within unused macro arguments?
  5. Date: 02 Feb 1996 18:16:14 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb2111614@qcd.lanl.gov>
  8. References: <DM3MC3.Atv@scr.siemens.com> <TANMOY.96Feb1102025@qcd.lanl.gov>
  9.     <4es8rp$98n@usenet.pa.dec.com>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11. Mime-Version: 1.0
  12. Content-Type: text
  13. In-reply-to: diamond@tko.dec.com's message of 2 Feb 1996 05:52:57 GMT
  14.  
  15. In article <4es8rp$98n@usenet.pa.dec.com> diamond@tko.dec.com (Norman
  16. Diamond) writes: 
  17. <snip>
  18.    >>Is the following program legal?
  19.    >>#define foo(unused)
  20.    >>#define bar(x,y)
  21.    >>foo(bar(1))
  22.  
  23.    >I read it as being legal.
  24.  
  25.    Mr. Bhattacharya, I am shocked.
  26.  
  27.    >>Excerpt from "6.8.3.1 Argument substitution"
  28.    >>  After the arguments for the invocation of a function-like macro have
  29.    >>  been identified, argument substitution takes place. A parameter in the
  30.    >>  replacment list, ..., is replaced by the corresponding argument after
  31.    >>  all macros contained therein have been expanded. Before being
  32.    >>  substituted, each argument's preprocessing tokens are completely macro
  33.    >>  replaced ... .
  34.  
  35.    >You gave the reason :-) The quoted text seems to imply the following order:
  36.    >  1) Identify parameters
  37.    [...]
  38.  
  39.    I think there's a preceding order as well:
  40.       0) constraints checked, including ANSI Classic section 3.8.3, page 90
  41.      lines 14 to 15:  "The number of arguments in an invocation of a
  42.      function-like macro shall agree with the number of parameters in
  43.      the macro definition, and [...]"
  44.  
  45. I think the important question is whether bar is ever invoked here. I
  46. read it as legal because I interpreted the wording as macros in
  47. parameters are invoked only if they appear in the replacement list not
  48. preceded by # or ## and not followed by ##; or if they are otherwise
  49. invoked during rescanning. 
  50.  
  51. Cheers
  52. Tanmoy
  53. --
  54. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  55. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  56. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  57. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  58. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  59. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  60.